﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Cms/Admin.Master" AutoEventWireup="true"
    CodeBehind="News.aspx.cs" Inherits="Aij1.Cms.News" %>

<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxHtmlEditor.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxHtmlEditor" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxSpellChecker.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxSpellChecker" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Xpo.v13.1.Web, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Xpo" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1 { width: 100%; }
        .style2 { width: 260px; }
    </style>
    <script type="text/javascript">
        function callback_CallbackComplete(s, e) {
            btnSubmit.SetEnabled(true);
            if (e.parameter == 'pick') {
                txtKeywords.SetText(e.result);
                return;
            }

            var key = e.result;
            lblTips.SetText(key);
            document.getElementById('hdnNewsId').value = s.cpNewsId;
            setTimeout("lblTips.SetText('')", 3000);

            if (chkSaveToLocal.GetChecked()) {
                location = 'News.aspx?Id=' + document.getElementById('hdnNewsId').value;
            }
        }

        function submit_Click(s, e) {
            btnSubmit.SetEnabled(false);
            lblTips.SetText("正在保存，请稍等......");
            callback.PerformCallback('submit');
        }

        function btnNew_Click(s, e) {
            var catId = cbxCategory.GetValue();
            location = 'News.aspx?CatId=' + catId;
        }

        function txtKeywords_ButtonClick(s, e) {
            txtKeywords.SetText("正在从本文提取关键词...");
            var html = edtContent.GetHtml();
            html = html.replace(/>\s*　+/gm, ">").replace(/>\s*(&nbsp;)+/gm, ">");
            if (!txtIntro.GetText()) {
                var intro = html.replace(/^([^<]*)<[\w\W]*/m, "$1");
                if (!intro || intro.length < 10) {
                    intro = html.replace(/<[^>]*>([^<]*)<[^>]*>[\w\W]*/m, "$1");
                }
                txtIntro.SetText(intro);
            }
            edtContent.SetHtml(html);
            btnSubmit.SetEnabled(false);
            callback.PerformCallback('pick');
        }
    </script>
</asp:Content>
<asp:Content ID="CT2" ContentPlaceHolderID="PH" runat="server">
    <input type="hidden" id="hdnNewsId" name="Id" value='<%=A.Oid %>' />
    <table width="760">
        <tr>
            <td width="70">
                标题:
            </td>
            <td>
                <dx:ASPxTextBox ID="txtTitle" runat="server" Width="100%" MaxLength="100">
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td>
                栏目:
            </td>
            <td>
                <table class="style1" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="style2" width="200">
                            <dx:ASPxComboBox ID="cbxCategory" runat="server" TextField="Title" ValueField="Oid"
                                ClientInstanceName="cbxCategory">
                            </dx:ASPxComboBox>
                        </td>
                        <td width="70">
                            作者:
                        </td>
                        <td>
                            <dx:ASPxTextBox ID="txtAuthor" runat="server" Width="170px" MaxLength="30">
                            </dx:ASPxTextBox>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                摘要:
            </td>
            <td>
                <dx:ASPxMemo ID="txtIntro" runat="server" Height="60px" Width="100%" ClientInstanceName="txtIntro">
                </dx:ASPxMemo>
            </td>
        </tr>
        <tr>
            <td>
                关键词:
            </td>
            <td>
                <dx:ASPxButtonEdit ID="txtKeywords" runat="server" ClientInstanceName="txtKeywords"
                    Width="100%" MaxLength="100">
                    <ClientSideEvents ButtonClick="txtKeywords_ButtonClick" />
                    <Buttons>
                        <dx:EditButton Text="提取">
                        </dx:EditButton>
                    </Buttons>
                </dx:ASPxButtonEdit>
            </td>
        </tr>
        <tr>
            <td>
                来源网址:
            </td>
            <td>
                <dx:ASPxTextBox ID="txtSourceUrl" runat="server" Width="100%" MaxLength="100">
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td>
                正文:
            </td>
            <td>
                <dx:ASPxHtmlEditor ID="edtContent" runat="server" Width="100%" ClientInstanceName="edtContent">
                    <SettingsImageUpload UploadImageFolder="">
                        <ValidationSettings AllowedFileExtensions=".jpe, .jpeg, .jpg, .gif, .png" MultiSelectionErrorText="注意! 
以下{0}个文件超过了({1})最大限制或文件扩展名不属于允许上传的范围. 这些文件将被从上传清单移除. 
{2}">
                        </ValidationSettings>
                    </SettingsImageUpload>
                    <SettingsImageSelector>
                        <CommonSettings AllowedFileExtensions=".jpe, .jpeg, .jpg, .gif, .png"></CommonSettings>
                    </SettingsImageSelector>
                    <SettingsDocumentSelector>
                        <CommonSettings AllowedFileExtensions=".rtf, .pdf, .doc, .docx, .odt, .txt, .xls, .xlsx, .ods, .ppt, .pptx, .odp">
                        </CommonSettings>
                    </SettingsDocumentSelector>
                </dx:ASPxHtmlEditor>
            </td>
        </tr>
        <tr>
            <td>
                发表时间:
            </td>
            <td>
                <table cellpadding="0" cellspacing="0" class="style1">
                    <tr>
                        <td width="180">
                            <dx:ASPxTimeEdit ID="dtDisplayTime" runat="server" EditFormat="DateTime" ClientInstanceName="dtDisplayTime">
                            </dx:ASPxTimeEdit>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnSetNow" runat="server" Text="设置当前时间" AutoPostBack="false">
                                <ClientSideEvents Click="function(s, e) {dtDisplayTime.SetDate(new Date());}" />
                            </dx:ASPxButton>
                        </td>
                        <td>
                            <dx:ASPxComboBox ID="cbxStatus" runat="server">
                            </dx:ASPxComboBox>
                        </td>
                        <td>
                            <dx:ASPxCheckBox ID="chkSaveToLocal" runat="server" Text="图片存到本地" ClientInstanceName="chkSaveToLocal">
                            </dx:ASPxCheckBox>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                <table class="style1">
                    <tr>
                        <td width="100">
                            <dx:ASPxButton ID="btnSubmit" runat="server" AutoPostBack="False" Text="提交" ClientInstanceName="btnSubmit"
                                Width="80px">
                                <ClientSideEvents Click="submit_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="100">
                            <dx:ASPxButton ID="btnReturn" runat="server" AutoPostBack="False" Text="返回" Width="80px">
                                <ClientSideEvents Click="function(s, e) {
	history.back();
}" />
                            </dx:ASPxButton>
                        </td>
                        <td width="100">
                            <dx:ASPxButton ID="btnNew" runat="server" Text="继续新建" Width="80px" AutoPostBack="False">
                                <ClientSideEvents Click="btnNew_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td>
                            <dx:ASPxCallback ID="ASPxCallback1" runat="server" ClientInstanceName="callback"
                                OnCallback="ASPxCallback1_Callback" OnCustomJSProperties="ASPxCallback1_CustomJSProperties">
                                <ClientSideEvents CallbackComplete="callback_CallbackComplete" />
                            </dx:ASPxCallback>
                            <dx:ASPxLabel ID="lblTips" runat="server" ClientInstanceName="lblTips" CssClass="tips">
                            </dx:ASPxLabel>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
